package com.miao.edu.boss.controller;

import com.miao.edu.api.AdRemoteService;
import com.miao.edu.common.entity.ResponseDTO;
import com.miao.edu.dto.PromotionSpaceDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author niemiao
 */
@RestController()
@RequestMapping("/ad")
public class AdController {

    @Autowired
    private AdRemoteService adRemoteService;

    @GetMapping("/ad/getAdByKey")
    public ResponseDTO<List<PromotionSpaceDTO>> getAdByKey(@RequestParam String[] keys) {
        List<PromotionSpaceDTO> allSpaces = adRemoteService.getAdByKey(keys);
        return ResponseDTO.success(allSpaces);
    }

    @GetMapping("/ad/{id}")
    public ResponseDTO<PromotionSpaceDTO> getPromotionSpaceById(@PathVariable("id") String id) {
        PromotionSpaceDTO promotionSpaceDTO = adRemoteService.getPromotionSpaceById(id);
        return ResponseDTO.success(promotionSpaceDTO);
    }
}
